package com.example.demo.entity;

import com.example.demo.rpc.DemoServiceProto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * Created with IntelliJ IDEA.
 *
 * @author hans
 * @version 1.0
 * @date 2024/11/20/14:13
 * @description proto中的any类型数据结构
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class ItemDetailEntity {

    private Long itemId;

    private String itemName;

    public ItemDetailEntity(DemoServiceProto.ItemDetail itemDetail) {
        this.itemId = itemDetail.getItemId();
        this.itemName = itemDetail.getItemName();
    }

    public DemoServiceProto.ItemDetail toItemDetail() {
        return DemoServiceProto.ItemDetail.newBuilder()
                .setItemId(itemId)
                .setItemName(itemName)
                .build();
    }

}
